{extend name="main" /}

{block name="title"}添加表名{/block}
{block name="body"}

<style>
    .layui-form-label {
        width: 150px;
    }

    .text-right{
        margin-top: 10px;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form id="myForm" lay-filter="myForm" class="layui-form model-form">
				
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label"><span class="red">*</span>表名：</label>
                        <div class="layui-input-inline">
                            <input id="table_name_zh" name="table_name_zh" placeholder="请输入表名" class="layui-input" autocomplete="off" lay-verType="tips" lay-verify="required"/>
                        </div>
                    </div>
                </div>


                <div class="layui-form-item text-right">
                    <button class="layui-btn" lay-filter="btnSave" lay-submit>保存</button>
                    <button class="layui-btn layui-btn-primary" type="button" mx-event="closeDialog">取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- 表格 -->


<script>
    //获取父级参数
    var mData = "";
    function child(obj){
        mData = JSON.parse(obj);
    }
    
	var curId=0;
	//表格数据
	var tableData=[];




	//Layui主运行函数
    layui.use(['form','admin','laydate','table','tableEdit','soulTable'], function () {
		var laydate = layui.laydate;
        var table = layui.table,
            soulTable = layui.soulTable,
			tableEdit = layui.tableEdit,
            form = layui.form;
            $ = layui.$;

			// 回显数据
			setTimeout(function(){
				form.val('myForm', mData);
			},500);


		

        // 保存

        form.on('submit(btnSave)', function (data) {
            // * 按钮禁用
            var isDisabled = $("#btnSave").hasClass('layui-btn-disabled');
            if (isDisabled) {
                return false;
            }
            // * 整合表单数据
            var formData = data.field;
            // * 确定路径
            var url = "{:url('table/table/addtable')}";

            // * 发起请求

            $.ajax({

                data: formData,

                type: "POST",

                dataType: "JSON",

                url: url,

                beforeSend: function () {
                    // 禁用
                    $("#btnSave").addClass('layui-btn-disabled');
                },
                complete: function () {
                    // 启用
                    $("#btnSave").removeClass('layui-btn-disabled');
                },
                success: function (result) {
                    if (result.code==1) {  
                        layer.msg(result.msg, {icon: 1});
                        window.parent.location.reload();//刷新父页面
                        parent.layer.close(parent.layer.getFrameIndex(window.name));

                    } else {
                        // 提示失败
                        layer.msg(result.msg, {icon: 5, anim: 6});
                    }
                }
            }); // end ajax
            return false;

        });

		
		
		
		
    });
</script>
{/block}
